<?php
class ContentPage_Model extends CI_Model{
	function ContentPage_Model(){
		parent::__construct();		
		$this->load->database();
	}
	function getReturnPolicy_Page($seller_id=0){
		$returnpolicy_content='';
		$this->db->where('seller_id',$seller_id);
		$this->db->where('page_name','Return Policy');
		$query=$this->db->get('content_page');
		if($query->num_rows() > 0) {
			$result=$query->first_row();
			$returnpolicy_content=$result->content_page;
		}
		return $returnpolicy_content;
	}
	
	function getProfile_Page($seller_id=0){
		$profile_content='';
		$this->db->where('seller_id',$seller_id);
		$this->db->where('page_name','Profile');
		$query=$this->db->get('content_page');
		if($query->num_rows() > 0) {
			$result=$query->first_row();
			$profile_content=$result->content_page;
		}
		return $profile_content;
	}
	function getTermsConditions_Page(){
		$termsconditions_content='';
		$this->db->where('seller_id',0);
		$this->db->where('page_name','termsconditions');
		$query=$this->db->get('content_page');
		if($query->num_rows() > 0) {
			$result=$query->first_row();
			$termsconditions_content=$result->content_page;
		}
		return $termsconditions_content;
	}
	function getContentPage($page_name,$seller_id){
		$this->db->where('seller_id',$seller_id);
		$this->db->where('page_name',$page_name);
		$result=$this->db->get('content_page');
		if($result->num_rows()>0){
			return $result->result_array();
		}else{
			$data_insert = array("seller_id"=>$seller_id,
								 "page_name"=>$page_name,
								 "content_page"=>"");
		    $this->db->insert('content_page', $data_insert);
		    $id = $this->db->insert_id();
		    $data_insert["id"] = $id;
		    $result2 = array();
		    $result2[0] = $data_insert;
		    return $result2; 
		}
		
	}
	function submitContentPage($id,$content_page){
		$update_data = array("content_page" =>$content_page,);
		$this->db->set("updated_at",'NOW()', FALSE);
		$this->db->where('id',$id);
		$this->db->update('content_page', $update_data);
		return 1;
	}
}
?>